package com.zhanghe.springsecurity.authentication;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * JWTAuthenticationToken
 *
 * @author Clevo
 * @date 2018/4/18
 */
public class JWTAuthenticationToken extends AbstractAuthenticationToken{

    public String refresh_token;

    public JWTAuthenticationToken(String refresh_token){
        super(null);
        this.refresh_token = refresh_token;
    }

    public JWTAuthenticationToken( String refresh_token,Collection<? extends GrantedAuthority> authorities ){
        super(authorities);
        this.refresh_token = refresh_token;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof JWTAuthenticationToken)) {
            return false;
        }
        JWTAuthenticationToken test = (JWTAuthenticationToken) obj;
        return test.getRefresh_token().equals(refresh_token);
    }

    public String getRefresh_token() {
        return refresh_token;
    }

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public Object getPrincipal() {
        return null;
    }
}
